package com.gosophia.conferenceManagement.common.ws.test.integrate;

import java.util.Calendar;
import java.util.List;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.gosophia.commons.exception.BusinessException;
import com.gosophia.conferenceManagement.ConferenceConfiguration;
import com.gosophia.conferenceManagement.common.ws.ConferenceHandleWebService;
import com.gosophia.conferenceManagement.starting.dto.ConferenceStartingDTO;
import com.gosophia.taskManagement.dto.JobDTO;
import com.gosophia.taskManagement.dto.JobHandleRecordsDTO;
import com.gosophia.taskManagement.ws.TaskManagementWebService;


public class ITConferenceHandleWebServiceImpl extends ConferenceJbpmProcessTestBase{

	@Autowired
	@Qualifier("conferenceHandleWebService")
	private ConferenceHandleWebService conferenceHandleWebService;
	@Autowired
	private TaskManagementWebService taskManagementWebService; 
	
	
	
  /**  @Test//测试开始会议的webservice
    public void testStartingConference() throws BusinessException{
        logger.info("测试会议发起开始");
       //1 无需申请的大型会议
        ConferenceStartingDTO testData = noApplicationAndLargeType();
        
       ConferenceStartingDTO  backData = conferenceHandleWebService.startingConferenceProcessing(testData);
        
        //判断返回任务的类别
        //判断已经完成的任务
        //判断是否能够正确更新数据
        Assert.assertEquals(testData.getConferenceName(), backData.getConferenceName());
        //待办
        List<JobDTO> todo1 = taskManagementWebService.findAllMyTodoJobByPage(testData.getConferenceCreatorId(), 100, 1, null, null)
                              .getResult();
        Assert.assertEquals(1, todo1.size());
        Assert.assertEquals("方案起草", todo1.get(0).getJobType());
        
        //已经完成的任务
        
         List<JobHandleRecordsDTO> history = taskManagementWebService.findJobHandleRecords(backData.getMissionId());
         for (JobHandleRecordsDTO jobHandleRecordsDTO : history) {
            logger.info("处理历史 的数据：操作名称 "+jobHandleRecordsDTO.getOperatorName()+" 任务类型 "+jobHandleRecordsDTO.getJobType());
        }
    
    }
    @Test//测试开始会议的webservice, 需要申请的大型会议
    public void testStartingConference2() throws BusinessException{
        logger.info("测试需要申请的大型会议发起开始");
        //1 需要申请的大型会议
        ConferenceStartingDTO testData = needApplicationAndLargeType();
        ConferenceStartingDTO  backData = conferenceHandleWebService.startingConferenceProcessing(testData);
        
        //判断返回任务的类别
        //判断已经完成的任务
        //判断是否能够正确更新数据
        Assert.assertEquals(testData.getConferenceName(), backData.getConferenceName());
        //待办
        List<JobDTO> todo1 = taskManagementWebService.findAllMyTodoJobByPage(testData.getConferenceCreatorId(), 100, 1, null, null)
        .getResult();
        Assert.assertEquals(1, todo1.size());
        Assert.assertEquals("申请审批取回", todo1.get(0).getJobType());
        
        //已经完成的任务
        
        List<JobHandleRecordsDTO> history = taskManagementWebService.findJobHandleRecords(backData.getMissionId());
        for (JobHandleRecordsDTO jobHandleRecordsDTO : history) {
            logger.info("处理历史 的数据：操作名称 "+jobHandleRecordsDTO.getOperatorName()+" 任务类型 "+jobHandleRecordsDTO.getJobType());
        }
        
    }
*/
    
    private ConferenceStartingDTO generateConferenceStartingDTO(String conferenceModel ,String conferenceType){
        return null;
    }
    
    //无需申请的大型会议
    private ConferenceStartingDTO noApplicationAndLargeType(){
        ConferenceStartingDTO cData = new ConferenceStartingDTO();
         cData.setConferenceModel(ConferenceConfiguration.NO_APPLICATION_CONFERENCE);//无需申请
         cData.setConferenceType(ConferenceConfiguration.LARGE_TYPE_CONFERENCE);//大型
         cData.setConferenceName("无需申请的大型会议名称");
         Long conferenceStartOperator =1000L;//测试用任务发起人
         cData.setConferenceCreatorId(conferenceStartOperator);
         cData.setImportentLevel(1014L);//普通
         Calendar cl =Calendar.getInstance();
         cl.set(2011, 12, 12);
         cData.setPlanEndTime(cl.getTime());
        return cData;
    }
    //需要申请的大型会议
    private ConferenceStartingDTO needApplicationAndLargeType(){
        ConferenceStartingDTO cData = new ConferenceStartingDTO();
        cData.setConferenceModel(ConferenceConfiguration.NEED_APPLICATION_CONFERENCE);//无需申请
        cData.setConferenceType(ConferenceConfiguration.LARGE_TYPE_CONFERENCE);//大型
        cData.setConferenceName("需申请的大型会议名称");
        Long conferenceStartOperator =1000L;//测试用任务发起人
        cData.setConferenceCreatorId(conferenceStartOperator);
        cData.setImportentLevel(1014L);//普通
        Calendar cl =Calendar.getInstance();
        cl.set(2011, 12, 12);
        cData.setPlanEndTime(cl.getTime());
        cData.setMajorIssue("test主题");
        cData.setConferenceDescription("测试描述");
        cData.setConfernceUnderTakerId(1000L);
        cData.setNextHandlerId(1001L);
        cData.setHandleAction("");
       return cData;
    }
    
    private List<JobDTO> findToJobs(){
        
        
        //taskManagementWebService.findAllMyTodoJobByPage(myUserInfoId, pageSize, pageNo, propertyFilters, orderConditions)
        return null;
    }
    
}
